<template>
  <div class="q-px-lg q-pb-md"></div>
</template>

<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import oauthApi from 'src/api/oauth/index';
@Component({
  components: {},
  async mounted() {
    this.$q.loading.show({
      message: '跳转中...'
    });
    this.$store.dispatch('headerCover/Init', {
      visible: false
    });
    const { code, state } = this.$route.query;
    const res = await oauthApi.callback(
      { code, state },
      localStorage.getItem('AUTH_SOURCE')
    );
    if (res.success) {
      await this.$store.dispatch('login/oauthLogin', res.data);
      this.$q.loading.hide();
      window.close();
    } else {
      alert(res.msg);
    }
  }
})
export default class Oauth extends Vue {}
</script>
